home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Catalog Service Access Module / DTS Sample CSAM / Src / AuditLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-24  |  4.1 KB  |  183 lines  |  [TEXT/KAHL]

  1. /*                                    AuditLibrary.c                                */
  2. /*
  3.  * AuditLibrary.c
  4.  * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
  5.  *
  6.  * Auditing for a few of the low-level AOCE directory service routines.
  7.  */
  8. #include "DTSSampleCSAM.h"
  9.  
  10. #if DEBUG_LOG
  11. void
  12. AuditLookupGetPB(
  13.         DirParamBlock            *pbPtr
  14.     )
  15. {
  16.         AuditPtr                auditPtr;
  17.         
  18.         auditPtr = GetAuditPtr(kCSAMCreatorID);
  19.         Audit(
  20.             auditPtr, 'AddD', AuditFormat2(
  21.                                 kAuditFormatSigned,
  22.                                 kAuditFormatAddress
  23.                             ),
  24.             (long) pbPtr->lookupGetPB.dsRefNum,
  25.             pbPtr->lookupGetPB.clientData
  26.         );
  27.         Audit(
  28.             auditPtr, 'AddD', AuditFormat7(
  29.                                 kAuditFormatAddress,
  30.                                 kAuditFormatAddress,
  31.                                 kAuditFormatUnsigned,
  32.                                 kAuditFormatUnsigned,
  33.                                 kAuditFormatSigned,
  34.                                 kAuditFormatAddress,
  35.                                 kAuditFormatUnsigned
  36.                             ),
  37.             pbPtr->lookupGetPB.aRecordList,
  38.             pbPtr->lookupGetPB.attrTypeList,
  39.             pbPtr->lookupGetPB.recordIDCount,
  40.             pbPtr->lookupGetPB.attrTypeCount,
  41.             (long) pbPtr->lookupGetPB.includeStartingPoint,
  42.             (long) pbPtr->lookupGetPB.getBuffer,
  43.             (long) pbPtr->lookupGetPB.getBufferSize
  44.         );
  45.         AuditRString(auditPtr, 'Attr',
  46.             &pbPtr->lookupGetPB.startingAttribute.attributeType
  47.         );
  48.         AuditRecordList(
  49.             auditPtr,
  50.             pbPtr->lookupGetPB.aRecordList,
  51.             pbPtr->lookupGetPB.recordIDCount
  52.         );
  53.         AuditAttributeTypeList(
  54.             auditPtr,
  55.             pbPtr->lookupGetPB.attrTypeList,
  56.             pbPtr->lookupGetPB.attrTypeCount
  57.         );
  58. }
  59.  
  60. void
  61. AuditRecordList(
  62.         AuditPtr                auditPtr,
  63.         RecordIDPtr                *aRecordList,
  64.         unsigned long            recordIDCount
  65.     )
  66. {
  67.         unsigned long                i;
  68.         
  69.         AuditStatusString(auditPtr, 'RLCT', recordIDCount, "\pRecord List");
  70.         for (i = 0; i < recordIDCount; i++)
  71.             AuditRecordID(auditPtr, aRecordList[i]);
  72. }
  73.  
  74. void
  75. AuditAttributeTypeList(
  76.         AuditPtr                auditPtr,
  77.         AttributeTypePtr        *attrTypeList,
  78.         unsigned long            attrTypeCount
  79.     )
  80. {
  81.         unsigned long                i;
  82.         
  83.         AuditStatusString(auditPtr, 'ATCT', attrTypeCount, "\pAttribute Type List");
  84.         for (i = 0; i < attrTypeCount; i++)
  85.             AuditAttributeType(auditPtr, attrTypeList[i]);
  86. }
  87.  
  88. void
  89. AuditRecordID(
  90.         AuditPtr                auditPtr,
  91.         RecordIDPtr                recordIDPtr
  92.     )
  93. {
  94.         AuditPackedRLIPtr(auditPtr, recordIDPtr->rli);
  95.         AuditLocalRecordID(auditPtr, &recordIDPtr->local);
  96. }
  97.  
  98.     
  99. void
  100. AuditPackedRLIPtr(
  101.         AuditPtr                auditPtr,
  102.         PackedRLIPtr            rliPtr
  103.     )
  104. {
  105.         RLI                        theRLI;
  106.         
  107.         if (rliPtr == NULL)
  108.             Audit(auditPtr, 'PRLI', kAuditFormatString, "\pNull RLI Ptr");
  109.         else if (OCEValidPackedRLI(rliPtr) == FALSE) {
  110.             Audit(auditPtr, 'PRLI', kAuditFormatString, "\pInvalid RLI Ptr");
  111.             Audit(auditPtr, 'PRLI', AuditFormat1(kAuditFormatAddress), rliPtr);
  112.         }
  113.         else {
  114.             OCEUnpackRLI(rliPtr, &theRLI);
  115.             Audit(
  116.                 auditPtr, 'PRLI', kAuditFormatString,
  117.                 OCERToPString((RString *) theRLI.directoryName)
  118.             );
  119.             Audit(
  120.                 auditPtr, 'PRLI',
  121.                 AuditFormat3(kAuditFormatHex, kAuditFormatAddress, kAuditFormatUnsigned),
  122.                 theRLI.discriminator.signature,
  123.                 theRLI.discriminator.misc,
  124.                 theRLI.dNodeNumber
  125.             );
  126.             AuditPath(auditPtr, theRLI.path);
  127.         }
  128. }
  129.  
  130. void
  131. AuditLocalRecordID(
  132.         AuditPtr                auditPtr,
  133.         LocalRecordIDPtr        localRecordIDPtr
  134.     )
  135. {
  136.         Audit(auditPtr, 'LRid', kAuditFormatString, "\pLocal record id");
  137.         Audit(
  138.             auditPtr,
  139.             'LRid',
  140.             AuditFormat2(kAuditFormatAddress, kAuditFormatAddress),
  141.             localRecordIDPtr->recordName,
  142.             localRecordIDPtr->recordType
  143.         );
  144.         AuditRString(auditPtr, 'LRid', localRecordIDPtr->recordName);
  145.         AuditRString(auditPtr, 'LRid', localRecordIDPtr->recordType);
  146. }
  147.  
  148.  
  149. void
  150. AuditPath(
  151.         AuditPtr                auditPtr,
  152.         PackedPathNamePtr        thePath
  153.     )
  154. {
  155.         unsigned short            nParts;
  156.         unsigned short            iParts;
  157.         RStringPtr                *partsVector;
  158.         
  159.         partsVector = NULL;
  160.         if (thePath == NULL)
  161.             Audit(auditPtr, 'Path', kAuditFormatString, "\pNull path");
  162.         else {
  163.             nParts = OCEDNodeNameCount(thePath);
  164.             Audit(auditPtr, 'nPat', AuditFormat1(kAuditFormatUnsigned),
  165.                 (unsigned long) nParts);
  166.             if (nParts <= 32) {
  167.                 partsVector = (RStringPtr *)
  168.                             NewPtrClear(nParts * sizeof (RStringPtr));
  169.                 if (partsVector != NULL) {
  170.                     iParts = OCEUnpackPathName(thePath, partsVector, nParts);
  171.                     for (; iParts > 0; --iParts) {
  172.                         AuditRString(auditPtr, 'Path', partsVector[iParts]);
  173.                     }
  174.                     DisposePtr((Ptr) partsVector);
  175.                 }
  176.             }
  177.         }
  178. }
  179. #endif /* DEBUG_LOG    */
  180.  
  181.  
  182.  
  183.